package cn.itcast.crm.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.itcast.crm.listener.PointRateListener;
import cn.itcast.crm.po.Customer;
import cn.itcast.crm.po.ext.CustomerQueryVO;
import cn.itcast.crm.utils.Page;

@Controller
@RequestMapping("/customer")
public class CustomerController {

	private static final Logger log = Logger.getLogger(CustomerController.class);

	@RequestMapping("/list")
	public String list(Model model, CustomerQueryVO vo) { 

		

		// request域数据：fromType、industryType、levelType
		model.addAttribute("fromType", "hello world");

		// 分页查询客户列表
		Customer c = new Customer();
		c.setCustId(1000L);
		Page<Customer> page = new Page<>();
		List<Customer> l = new ArrayList<Customer>();
		l.add(c);
		page.setRows(l);
		// request域数据：custName\custSource\custIndustry\custLevel\Page
		model.addAttribute("page", page);

		// 回显数据
		if (vo.getCustomer() != null) {
			model.addAttribute("custName", vo.getCustomer().getCustName());
			model.addAttribute("custSource", vo.getCustomer().getCustSource());
			model.addAttribute("custIndustry", vo.getCustomer().getCustIndustry());
			model.addAttribute("custLevel", vo.getCustomer().getCustLevel());
		}
		return "index";
	}
}
